import { Controller, Get } from '@nestjs/common';
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
import { ApiTenantHeader } from '~/common/decorators/api-header-tenant.decorator';
import { ModuleSwaggerTags } from '~/constants/modules.constant';
import { AuthUser } from '~/modules/auth/decorators/auth-user.decorator';
import { Public } from '~/modules/auth/decorators/public.decorator';
import { SurveyService } from '~/modules/survey/survey.service';
import { AuthTenant } from '~/modules/tenant/tenant.decorator';
import { UserService } from '~/modules/user/user.service';

@ApiBearerAuth()
@ApiTags(ModuleSwaggerTags.SURVEY)
@Controller('survey')
export class MiniappSurveyController {
	constructor(
		private readonly surveyService: SurveyService,
		private readonly userService: UserService, // 假设你需要用户服务
	) {}

	@Public()
	@Get()
	@ApiOperation({ summary: '获取问卷列表' })
	@ApiTenantHeader()
	async getSurveyList(@AuthTenant() tenant: IAuthTenant, @AuthUser() user: IAuthUser): Promise<{survey: string, quiz: string}> {
		const diseaseId = await this.userService.getUserDisease(user?.uid);
		// 获取问卷列表
		return await this.surveyService.findByTenantId(tenant.id, diseaseId);
	}
}
